//公共网络请求
import { baseUrl } from "./config";

//获取所有榜单内容摘要  /toplist/detail
export function topList(){
	
	return new Promise(function(reslove,reject){
		uni.request({
			url:`${baseUrl}/toplist/detail`,
			success: res => {
				let result = res.data.list
				//只取数据最新四个
				result.length = 4
				reslove(result)
			}
		})
	})
	
}

//获取指定榜单详情内容 /playlist/detail
export function playListDetail(listId){
	return uni.request({
		url:`${baseUrl}/playlist/detail?id=${listId}`
	})
}

//获取歌曲详情数据  /song/detail
export function songDetail(songId){
	return uni.request({
		url:`${baseUrl}/song/detail?ids=${songId}`
	})
}

//获取相似音乐 /simi/song
export function simiSong(songId){
	return uni.request({
		url:`${baseUrl}/simi/song?id=${songId}`
	})
}

//获取歌曲评论 /comment/music
export function commentMusic(songId){
	return uni.request({
		url:`${baseUrl}/comment/music?id=${songId}`
	})
}

//获取歌曲歌词 
export function lyric(songId){
	return uni.request({
		url:`${baseUrl}/lyric?id=${songId}`
	})
}

//获取音乐 url /song/url
export function songUrl(songId){
	return uni.request({
		url:`${baseUrl}/song/url?id=${songId}`
	})
}

//获取热搜列表(详细) /search/hot/detail
export function searchHot(){
	return uni.request({
		url:`${baseUrl}/search/hot/detail`
	})
}

//搜索 /search?keywords=xxx
export function searchWord(word){
	return uni.request({
		url:`${baseUrl}/search?keywords=${word}`
	})
}

//搜索建议 /search/suggest?keywords=xxx&type=mobile
export function searchSuggest(word){
	return uni.request({
		url:`${baseUrl}/search/suggest?keywords=${word}&type=mobile`
	})
}